<?php
#sample comment
define('APP_NAME', 'whisper.net');
define('QUEUE_PATH', '/var/www/shadow.net/client');
define('QUEUE_DATA', '/var/www/temp/queue');
define('ARTICLE_CLIENT', 'queue.article');
define('THREADED_ARTICLE_CLIENT', 'queue.thread.article');
define('DATA_PATH', '/var/www/temp/data');

define('USER_AGENT', $_SERVER['HTTP_USER_AGENT']);
define('IPHONE_UI', strpos (USER_AGENT, 'iPhone') === false ? false : true); 
define('SILK_UI', strpos (USER_AGENT, 'Silk') === false ? false : true); 
define('TABLET_TEXT_LENGTH', IPHONE_UI ? 35 : (SILK_UI ? 50 : 65)); 
define('WEB_PAGE_SIZE', 8);
define('TABLET_PAGE_SIZE', 10);
define('VIDEO_WIDTH', IPHONE_UI ? 180 : 640);

define('PREVIEW_COUNT', 9);

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';


/*
* database connection
*/

require ('../client/usenet.db.php');

function deSubject($str) {
	if (strpos($str, '&quot;')!==false)
	    $str = html_entity_decode($str);
//	if (preg_match('/.*\s+"(\S+\.\w{3})"/', $str, $temp))
	if (preg_match('/.*"([^"]*)".*/ims', $str, $temp))
	    return $temp[1];
	else if (preg_match('/.*\s+(\S+\.\w{3})/', $str, $temp))
	    return str_replace('&quot;', '', $temp[1]);
	else return $str;
}

function is_video($t) {
    return $t=='m4v' || $t=='wmv'; 
}

function plural($n) { 
    return $n==1?'':'s';
}

function trunk($text, $limit=30) { 
    $value=html_entity_decode( $text );
    if (strlen($value)<$limit) return $value;
    $half=$limit/2;
    $start = substr($value, 0, $half);
    $end   = substr($value, strlen($value) - $half);
     if (strpos($start,'<')!==false)
        $start = htmlentities ($start);
    return $start . '...' . $end;
}

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();
